WPS Office.apk(点击下载) / dtp.java


package defpackage;

import android.support.v4.app.NotificationCompat;
import android.text.TextUtils;
import cn.wps.moffice.OfficeApp;
import cn.wps.moffice.common.infoflow.internal.cards.template.AuthorAboutInfo;
import cn.wps.moffice.common.infoflow.internal.cards.thirdpartyad.ThirdPartyAdParams;
import com.baidu.tts.loopj.AsyncHttpResponseHandler;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import com.iflytek.cloud.SpeechEvent;
import com.iflytek.cloud.SpeechUtility;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/* renamed from: dtp  reason: default package */
public final class dtp {

    /* renamed from: dtp$a */
    public static class a {
        public static dtp edL = new dtp();
    }

    private static JSONObject lA(String str) {
        try {
            JSONObject jSONObject = new JSONObject(str);
            if ("ok".equals(jSONObject.get(SpeechUtility.TAG_RESOURCE_RESULT)) && jSONObject.has(SpeechEvent.KEY_EVENT_RECORD_DATA)) {
                return jSONObject.getJSONObject(SpeechEvent.KEY_EVENT_RECORD_DATA);
            }
        } catch (JSONException e) {
            e.toString();
        }
        return null;
    }

    private static JSONArray lB(String str) {
        try {
            JSONObject jSONObject = new JSONObject(str);
            if ("ok".equals(jSONObject.get(SpeechUtility.TAG_RESOURCE_RESULT)) && jSONObject.has(SpeechEvent.KEY_EVENT_RECORD_DATA)) {
                return jSONObject.getJSONArray(SpeechEvent.KEY_EVENT_RECORD_DATA);
            }
        } catch (JSONException e) {
            e.toString();
        }
        return null;
    }

    public static double lu(String str) {
        HashMap hashMap = new HashMap();
        hashMap.put("X-Requested-With", "XMLHttpRequest");
        hashMap.put("Cookie", String.format("wps_sid=%s", str));
        try {
            JSONObject jSONObject = new JSONObject(lwd.f("https://docer.wps.cn/v3.php/api/android/memtype/member_discount", hashMap));
            if ("ok".equals(jSONObject.get(SpeechUtility.TAG_RESOURCE_RESULT))) {
                return jSONObject.optDouble(SpeechEvent.KEY_EVENT_RECORD_DATA, 1.0d);
            }
            return 1.0d;
        } catch (IOException e) {
            e.toString();
            return 1.0d;
        } catch (JSONException e2) {
            e2.toString();
            return 1.0d;
        }
    }

    public static dts lw(String str) {
        try {
            return (dts) lvb.b(str, dts.class);
        } catch (Exception e) {
            e.toString();
            return null;
        }
    }

    private List<dts> lx(String str) {
        dts[] dtsArr;
        try {
            JSONObject lA = lA(str);
            if (!(lA == null || (dtsArr = (dts[]) lvb.b(lA.getString(SpeechEvent.KEY_EVENT_RECORD_DATA), dts[].class)) == null)) {
                return Arrays.asList(dtsArr);
            }
        } catch (JSONException e) {
            e.toString();
        }
        return null;
    }

    private dtw ly(String str) {
        try {
            JSONObject lA = lA(str);
            if (lA != null) {
                dtw dtw = new dtw();
                if (lA.has("count")) {
                    dtw.efR = lA.getInt("count");
                }
                if (!lA.has("big")) {
                    return dtw;
                }
                JSONArray jSONArray = lA.getJSONArray("big");
                ArrayList arrayList = new ArrayList(jSONArray.length());
                for (int i = 0; i < jSONArray.length(); i++) {
                    JSONObject jSONObject = jSONArray.getJSONObject(i);
                    if (jSONObject.has("image_url")) {
                        arrayList.add(jSONObject.getString("image_url"));
                    }
                }
                dtw.efS = lA.optString("gif_url");
                dtw.efQ = arrayList;
                return dtw;
            }
        } catch (JSONException e) {
            e.toString();
        }
        return null;
    }

    private AuthorAboutInfo lz(String str) {
        try {
            JSONObject lA = lA(str);
            if (lA != null) {
                return (AuthorAboutInfo) lvb.b(lA.toString(), AuthorAboutInfo.class);
            }
        } catch (Exception e) {
            e.toString();
        }
        return null;
    }

    public final List<dts> N(int i, int i2, int i3) {
        HashMap hashMap = new HashMap();
        hashMap.put("X-Requested-With", "XMLHttpRequest");
        try {
            List<dts> lx = lx(lwd.f(String.format("https://docer.wps.cn/v3.php/api/android/mb/v2/rec_data?mb_app=%d&limit=%d&offset=%d&del_img_scale=%s&type=%s", Integer.valueOf(i), Integer.valueOf(i2), 0, "1", "hot3"), hashMap));
            gnb.bB(lx);
            return lx;
        } catch (IOException e) {
            e.toString();
            return null;
        }
    }

    public final String a(String str, String str2, String str3, String str4, String str5) {
        HashMap hashMap = new HashMap();
        hashMap.put("X-Requested-With", "XMLHttpRequest");
        hashMap.put("Cookie", String.format("wps_sid=%s", str2));
        if (str3 == null) {
            str3 = "";
        }
        if (str4 == null) {
            str4 = "";
        }
        if (str5 == null) {
            str5 = "";
        }
        try {
            JSONObject lA = lA(lwd.f(String.format("https://docer.wps.cn/v3.php/api/android/mb/download?id=%s&is_https=1&version=4&sn=%s&channel=%s&sub_channel=%s&ver=%s", str, str3, str4, URLEncoder.encode(str5, AsyncHttpResponseHandler.DEFAULT_CHARSET), OfficeApp.arx().cqM), hashMap));
            if (lA != null && lA.has("mb_url")) {
                return lA.getString("mb_url");
            }
        } catch (IOException e) {
            e.toString();
        } catch (JSONException e2) {
            e2.toString();
        }
        return null;
    }

    public final dtn ap(String str, String str2) {
        HashMap hashMap = new HashMap();
        hashMap.put("X-Requested-With", "XMLHttpRequest");
        hashMap.put("Cookie", String.format("wps_sid=%s", str2));
        try {
            JSONObject lA = lA(lwd.f(String.format("https://docer.wps.cn/v3.php/api/android/mb/buy_info?id=%s&version=3", str), hashMap));
            if (lA != null) {
                return (dtn) lvb.b(lA.toString(), dtn.class);
            }
            return null;
        } catch (IOException e) {
            e.toString();
            return null;
        }
    }

    public final int aq(String str, String str2) {
        try {
            HashMap hashMap = new HashMap();
            hashMap.put("cookie", "wps_sid=" + cqy.asP());
            HashMap hashMap2 = new HashMap();
            hashMap2.put("group", str);
            hashMap2.put("position", "android_receive_coupons");
            hashMap2.put("name", str2);
            String c = lwd.c("https://vip.wps.cn/coupon/banner/receive", lwd.r(hashMap2), hashMap);
            JSONObject jSONObject = new JSONObject(c);
            if (!ThirdPartyAdParams.ACTION_AD_ERROR.equals(jSONObject.optString(SpeechUtility.TAG_RESOURCE_RESULT)) || !"max_limit".equals(jSONObject.optString(NotificationCompat.CATEGORY_MESSAGE))) {
                return ((duc) lvb.b(lA(c).toString(), duc.class)).state;
            }
            return 2;
        } catch (Exception e) {
            e.toString();
            return 0;
        }
    }

    public final List<dts> b(int i, String str, int i2, int i3) {
        HashMap hashMap = new HashMap();
        hashMap.put("X-Requested-With", "XMLHttpRequest");
        try {
            List<dts> lx = lx(lwd.f(String.format("https://docer.wps.cn/v3.php/api/android/mb/v2/link_data?mb_app=%d&limit=%d&offset=%d&link=%s&del_img_scale=%s&file_type=%s", Integer.valueOf(i), Integer.valueOf(i2), 0, str, "1", "1"), hashMap));
            gnb.bB(lx);
            return lx;
        } catch (IOException e) {
            e.toString();
            return null;
        }
    }

    public final AuthorAboutInfo lv(String str) {
        HashMap hashMap = new HashMap();
        hashMap.put("X-Requested-With", "XMLHttpRequest");
        try {
            return lz(lwd.f(String.format("https://docer.wps.cn/v3.php/api/author?author_id=%s", str), hashMap));
        } catch (IOException e) {
            e.toString();
            return null;
        }
    }

    public final cte p(int i, String str) {
        HashMap hashMap = new HashMap();
        hashMap.put("X-Requested-With", "XMLHttpRequest");
        try {
            return (cte) new GsonBuilder().excludeFieldsWithoutExposeAnnotation().create().fromJson(lwd.f(String.format("https://docer.wps.cn/v3.php/api/android/mb/v3?mb_app=%d&id=%s", Integer.valueOf(i), str), hashMap), new TypeToken<cte>() {
                /* class defpackage.dtp.AnonymousClass1 */
            }.getType());
        } catch (IOException e) {
            e.toString();
            return null;
        }
    }

    public final Map<String, String> qu(int i) {
        HashMap hashMap = new HashMap();
        hashMap.put("X-Requested-With", "XMLHttpRequest");
        try {
            JSONArray lB = lB(lwd.f(String.format("https://docer.wps.cn/v3.php/api/android/mb/v2/rec_link?mb_app=%d", Integer.valueOf(i)), hashMap));
            if (lB != null) {
                HashMap hashMap2 = new HashMap();
                for (int i2 = 0; i2 < lB.length(); i2++) {
                    JSONObject jSONObject = lB.getJSONObject(i2);
                    String string = jSONObject.has("text") ? jSONObject.getString("text") : "";
                    String str = "";
                    if (jSONObject.has("link")) {
                        str = jSONObject.getString("link");
                    }
                    if (!TextUtils.isEmpty(string) && !TextUtils.isEmpty(str)) {
                        hashMap2.put(string, str);
                    }
                }
                return hashMap2;
            }
        } catch (IOException e) {
            e.toString();
        } catch (JSONException e2) {
            e2.toString();
        }
        return null;
    }

    public final dtw r(String str, String str2, String str3) {
        HashMap hashMap = new HashMap();
        hashMap.put("X-Requested-With", "XMLHttpRequest");
        if (str2 == null) {
            str2 = "";
        }
        if (str3 == null) {
            str3 = "";
        }
        try {
            return ly(lwd.f(String.format("https://docer.wps.cn/v3.php/api/android/mb/preview?id=%s&channel=%s&sub_channel=%s&ver=%s", str, str2, URLEncoder.encode(str3, AsyncHttpResponseHandler.DEFAULT_CHARSET), OfficeApp.arx().cqM), hashMap));
        } catch (IOException e) {
            e.toString();
            return null;
        }
    }
}